package My

import (
	"db2s/global"
	"reflect"
)

type SchemaObjectMeta struct {
}

func getCreateObjectTypeFunc() (res map[string]reflect.Value) {
	return map[string]reflect.Value{
		"job":       reflect.ValueOf(createJob),
		"view":      reflect.ValueOf(createView),
		"seq":       reflect.ValueOf(createSeq),
		"type":      reflect.ValueOf(createType),
		"trigger":   reflect.ValueOf(createTrigger),
		"foreign":   reflect.ValueOf(createForeign),
		"func":      reflect.ValueOf(createFunc),
		"procedure": reflect.ValueOf(createProcedure),
		"package":   reflect.ValueOf(createPackage),
	}
}
func (my SchemaObjectMeta) Create(s global.SchemaObjectInput) (res global.SchemaObjectReturnResult, err error) {
	if v, ok := getCreateObjectTypeFunc()[s.Type]; ok {
		args := []reflect.Value{reflect.ValueOf(s)}
		funcRes := v.Call(args)
		for x, y := range funcRes {
			switch x {
			case 0:
				res.FixSql = y.Interface().(global.ObjectFixSqlS)
			}
		}
	}
	return
}
